#include <cstdio>

const int MAXN = 15;

int n;
int tot;
int C[MAXN];

void search(int cur) {
	if (cur == n) {
		tot++;
		return;
	}
	for (int i = 0; i < n; i++) {
		bool ok = true;
		C[cur] = i;
		for (int j = 0; j < cur; j++) {
			if (C[cur] == C[j] || cur - C[cur] == j - C[j] || cur + C[cur] == j + C[j]) {
				ok = false;
				break;
			}
		}
		if (ok) search(cur + 1);
	}
}

int main() {
	n=13;
	
	search(0);
	
	printf("%d", tot);
}
